home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / ShareMailGiftware / AmigaTalk / general / Class.st < prev    next >
Text File  |  2002-10-27  |  3KB  |  124 lines

  1. " ----------------------------------------------------------"
  2. " Added getByteArray: methodString  method on 09/26/98.     "
  3. "-----------------------------------------------------------"
  4.  
  5. Class Class
  6. [
  7.   edit
  8.     <primitive 150 self>
  9. |
  10.   list
  11.     <primitive 157 self>
  12. |
  13.   basicNew        ! superclass newinstance !
  14.     superclass <- <primitive 151 self>.         " Get the Parent Class. "
  15.  
  16.     <primitive 3 superclass>                    " Parent respondsTo: new?? "
  17.       ifTrue: [newinstance <- superclass new].
  18.  
  19.     newinstance <- <primitive 153 self newinstance>. "Make a new instance"
  20.  
  21.     " The space after the '#new' string is needed by the parser in order"
  22.     " to find the terminating '>' of the primitive!"
  23.  
  24.     <primitive 155 self #new >                       "new object respondsTo: new???" 
  25.       ifTrue: [newinstance <- newinstance new].
  26.  
  27.     ^ newinstance
  28. |
  29.   new ! newObject test !
  30.     (<primitive 91 #Singleton_Class <primitive 250 4 0 self>>)
  31.  
  32.        ifTrue: [ " This Class is a Singleton Class, so see if it's
  33.                  * been initialized yet:
  34.                  "
  35.                  test <- <primitive 250 4 3 self>.
  36.         
  37.                  (test == nil)
  38.                    ifTrue: [ " Initialize this Singleton Class: "
  39.                              newObject <- self basicNew.
  40.  
  41.                              <primitive 250 4 4 self newObject>.
  42.  
  43.                              ^ newObject
  44.                            ].
  45.  
  46.                  " Singleton Class is already initialized: "
  47.                  ^ test
  48.                ].
  49.  
  50.     " This Class is an Ordinary Class: "       
  51.     ^ self basicNew 
  52. |
  53.   basicNew: aValue  ! superclass newinstance !
  54.     superclass <- <primitive 151 self>.
  55.  
  56.     <primitive 3 superclass>
  57.       ifTrue: [newinstance <- superclass new ]. 
  58.  
  59.     newinstance <- <primitive 153 self newinstance>.
  60.  
  61.     " The space after the '#new:' string is needed by the parser in order"
  62.     " to find the terminating '>' of the primitive!"
  63.  
  64.     <primitive 155 self #new: >
  65.       ifTrue: [newinstance <- newinstance new: aValue].
  66.  
  67.     ^ newinstance
  68. |
  69.   new: aValue ! newObject test ! 
  70.     (<primitive 91 #Singleton_Class <primitive 250 4 0 self>>)
  71.  
  72.        ifTrue: [ " This Class is a Singleton Class, so see if it's
  73.                  * been initialized yet:
  74.                  "
  75.                  test <- <primitive 250 4 3 self>.
  76.         
  77.                  (test == nil)
  78.                    ifTrue: [ " Initialize this Singleton Class: "
  79.                              newObject <- self basicNew: aValue.
  80.                              
  81.                              <primitive 250 4 4 self newObject>.
  82.                              
  83.                              ^ newObject
  84.                            ].
  85.  
  86.                  " Singleton Class is already initialized: "
  87.                  ^ test
  88.                ].
  89.        
  90.     " This Class is an Ordinary Class: "
  91.     ^ self basicNew: aValue
  92. |
  93.   printClassString
  94.     ^ <primitive 152 self>
  95. |
  96.   respondsTo
  97.     <primitive 154 self>
  98. |
  99.   respondsTo: aSymbol ! aClass !
  100.     aClass <- self.
  101.  
  102.     [aClass notNil] 
  103.        whileTrue:
  104.            [ <primitive 155 aClass aSymbol> 
  105.                ifTrue: [ ^ true ].
  106.              
  107.              aClass <- aClass superClass 
  108.            ].
  109.  
  110.     ^ false
  111. |
  112.   superClass
  113.     ^ <primitive 151 self>
  114. |
  115.   variables
  116.     ^ <primitive 158 self>
  117. |
  118.   view
  119.     <primitive 156 self>
  120. |
  121.   getByteArray: methodString
  122.     ^ <primitive 159 self methodString> "159 was an unused primitive."
  123. ]
  124.